package com.cy.pj.sys.dao;

import com.cy.pj.sys.pojo.SysRole;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author 张琪
 * @date 2020/11/14
 * @describe
 */

@Mapper
public interface SysRoleMenuDao {

    @Delete("delete from sys_role_menus where menu_id = #{id}")
    int deleteObjectsByMenuId(Integer id);

    /**
     * 保存角色和菜单关系数据
     * @param roleId
     * @param menuIds
     * @return
     */
    int insertObjects(Integer roleId, Integer[] menuIds);

    @Select("select menu_id from sys_role_menus where role_id = #{roleId}")
    List<Integer> findMenuIdsById(Integer id);
//
//    @Delete("delete from sys_role_menus where role_id = #{id}")
//    int deleteObjectsByRoleId(Integer id);

    List<Integer> findMenuIdsByIds(List<Integer> roleIds);

}
